﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class StoreBL
	{

		#region ***** Init Methods ***** 
		StoreDA objStoreDA;
		public StoreBL()
		{
			objStoreDA = new StoreDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Store by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Store</returns>
		public Store GetByID(int id)
		{
			return objStoreDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Store
		/// </summary>
		/// <returns>List<<Store>></returns>
		public List<Store> GetList()
		{
			string cacheName = "lstStore";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objStoreDA.GetList(), "Store");
			}
			return (List<Store>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Store
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsStore";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objStoreDA.GetDataSet(), "Store");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Store paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Store>></returns>
		public List<Store> GetListPaged(int recperpage, int pageindex)
		{
			return objStoreDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Store paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objStoreDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Store within Store database table
		/// </summary>
		/// <param name="obj_store">Store</param>
		/// <returns>key of table</returns>
		public int Add(Store obj_store)
		{
			ServerCache.Remove("Store", true);
			return objStoreDA.Add(obj_store);
		}

		/// <summary>
		/// updates the specified Store
		/// </summary>
		/// <param name="obj_store">Store</param>
		/// <returns></returns>
		public void Update(Store obj_store)
		{
			ServerCache.Remove("Store", true);
			objStoreDA.Update(obj_store);
		}

		/// <summary>
		/// Delete the specified Store
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Store", true);
			objStoreDA.Delete(id);
		}
		#endregion
	}
}
